package cn.edu.scujcc.customofsichuan;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import java.util.ArrayList;
import java.util.List;

import cn.edu.scujcc.customofsichuan.Adapter.ViewPagerAdapter;

public class home extends Fragment {
    private Context context;//必须获取上下文
    Intent intent;
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View v =  inflater.inflate(R.layout.fragment_home, container, false);//根视图，也是容器，为帧布局填充布局
        List<View> viewList=new ArrayList<>();
        context = getContext();//获取上下文,帧布局中没有startAcitivity方法。

        View waiting_card=inflater.inflate(R.layout.waiting_card,null);
        View huobajie=inflater.inflate(R.layout.huobajie_card,null);
        View dafojie=inflater.inflate(R.layout.dafojie_card,null);
        View miaohui=inflater.inflate(R.layout.guichengmiaohui_card,null);
        View rdj_card = inflater.inflate(R.layout.rdj_card,null);
        View ezj_card = inflater.inflate(R.layout.ezj_card,null);
        View zsh_card = inflater.inflate(R.layout.zsh_card,null);
        View fsj_card = inflater.inflate(R.layout.fsj_card, null);

        viewList.add(huobajie);
        viewList.add(miaohui);
        viewList.add(rdj_card);
        viewList.add(ezj_card);
        viewList.add(zsh_card);
        viewList.add(fsj_card);
        viewList.add(dafojie);
        viewList.add(waiting_card);


        ViewPager viewPager=v.findViewById(R.id.view_pager);
        ViewPagerAdapter viewPagerAdapter = new ViewPagerAdapter(viewList);
        viewPager.setAdapter(viewPagerAdapter);

        huobajie.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                intent=new Intent(context, Second_huobajie.class);
                startActivity(intent);
            }
        });
        dafojie.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                intent=new Intent(context,Second_dafojie.class);
                startActivity(intent);
            }
        });
        miaohui.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                intent=new Intent(context,Second_miaohui.class);
                startActivity(intent);
            }
        });

        rdj_card.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                intent=new Intent(context,Second_rdj.class);
                startActivity(intent);
            }
        });
        zsh_card.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                intent=new Intent(context,Second_zsh.class);
                startActivity(intent);
            }
        });
        ezj_card.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                intent=new Intent(context,Second_ezj.class);
                startActivity(intent);
            }
        });

        fsj_card.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                intent=new Intent(context,Second_fsj.class);
                startActivity(intent);
            }
        });
        waiting_card.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

            }
        });
        return v;
    }

}